home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 138
/
Volume 138 Aug 19 2011 - Damaged.iso
/
Games
/
shadez.swf
/
scripts
/
Local
/
CMain.as
< prev
next >
Wrap
Text File
|
2011-08-19
|
7KB
|
222 lines
package Local
{
import Local.Draw.CScreen;
import Local.Draw.CScreen_Debrief;
import Local.Draw.CScreen_LoadingLevel;
import Local.External.CKongregate;
import Local.Game.CGame;
import STC9.System.CProfiler;
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.geom.Rectangle;
public class CMain extends MovieClip
{
public static var mMinSize:Rectangle = new Rectangle(0,0,700,550);
public static var mMaxSize:Rectangle = new Rectangle(0,0,700,550);
public static var mSize:Rectangle = new Rectangle(0,0,700,550);
private var mScreens:CScreen;
public var mcTimer:MovieClip;
public var mProfiler:CProfiler;
private var mGame:CGame;
public function CMain()
{
if(true)
{
super();
if(true)
{
addEventListener(Event.ADDED_TO_STAGE,Initialize);
}
opaqueBackground = 0;
}
}
public function UpdateTimer(param1:int) : void
{
var _loc2_:String = null;
var _loc3_:String = null;
var _loc4_:String = null;
var _loc5_:String = null;
if(!CGlobal.mShowVideoTimer)
{
return;
}
_loc2_ = String(Math.floor(param1 % CGame.SECONDS));
_loc3_ = String(Math.floor(param1 / CGame.SECONDS) % 60);
_loc4_ = String(Math.floor(param1 / (CGame.SECONDS * 60)) % 60);
_loc5_ = String(Math.floor(param1 / (CGame.SECONDS * 60 * 60)) % 24);
mcTimer.tbTimer.text = p0(_loc5_) + ":" + p0(_loc4_) + ":" + p0(_loc3_) + "." + p0(_loc2_);
}
private function e_GAME_LOADED(param1:Event = null) : void
{
var _loc2_:CScreen_LoadingLevel = null;
_loc2_ = CScreen_LoadingLevel(param1.currentTarget);
var _loc3_:*;
mGame = _loc3_ = _loc2_.mGame;
addChildAt(_loc3_,0);
mScreens.Deactivate();
mGame.addEventListener(CGame.GAME_COMPLETE,e_GAME_COMPLETE);
mGame.addEventListener(CGame.GAME_EXIT,e_GAME_EXIT);
mGame.addEventListener(CGame.GAME_DIED,e_GAME_DIED);
CProfiler.Reset();
e_RESIZE();
}
public function Initialize(param1:Event = null) : void
{
removeEventListener(Event.ADDED_TO_STAGE,Initialize);
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
addEventListener(Event.ENTER_FRAME,Update);
stage.addEventListener(Event.RESIZE,e_RESIZE);
CGlobal.Open();
mProfiler = new CProfiler("left","fpsonly");
if(CGlobal.mProfiler)
{
addChild(mProfiler);
}
mScreens = new CScreen();
addChildAt(mScreens,0);
§§push(mScreens);
§§push("main");
if(true)
{
§§pop().AddScreen(§§pop(),new Screen_Main());
mScreens.AddScreen("selectlevel",new Screen_SelectLevel());
mScreens.AddScreen("loadinglevel",new Screen_LoadingLevel()).addEventListener(CScreen_LoadingLevel.GAME_LOADED,e_GAME_LOADED);
mScreens.AddScreen("debrief",new Screen_Debrief());
§§push(mScreens);
§§push("main");
}
§§pop().GetScreen(§§pop()).Activate();
mcTimer.visible = CGlobal.mShowVideoTimer;
CKongregate.Load(this);
e_RESIZE();
}
private function e_GAME_DIED(param1:Event = null) : void
{
if(true)
{
e_GAME_COMPLETE(param1,"died");
}
}
private function e_GAME_COMPLETE(param1:Event = null, param2:String = "complete") : void
{
if(true)
{
CScreen_Debrief.mScore = mGame.mScore;
if(true)
{
CScreen_Debrief.mGameState = param2;
if(true)
{
mGame.Dispose();
if(true)
{
removeChild(mGame);
if(true)
{
mGame = null;
addChildAt(mScreens,0);
}
CProfiler.Reset();
}
e_RESIZE();
}
UpdateTimer(0);
}
mScreens.GetScreen("debrief").Activate();
}
}
public function e_RESIZE(param1:Event = null) : void
{
if(true)
{
§§push(mGame);
if(true)
{
§§goto(addr21);
}
§§pop().Resize(mSize.width,mSize.height);
}
addr21:
if(§§pop())
{
§§push(mGame);
}
}
private function p0(param1:String) : String
{
§§push(param1);
if(true)
{
if(§§pop().length < 2)
{
§§push("0" + param1);
if(true)
{
}
§§goto(addr31);
}
else
{
§§push(param1);
}
§§push(§§pop());
}
addr31:
return §§pop();
}
public function Update(param1:Event = null) : void
{
CProfiler.StopProfile("_frame.Update");
mProfiler.Update(true);
CProfiler.StartProfile("_frame.Update");
§§push(mGame);
if(true)
{
if(§§pop())
{
addr30:
mGame.Update();
}
§§push(mScreens);
if(true)
{
if(§§pop().parent)
{
addr44:
mScreens.Process();
}
return;
}
§§goto(addr44);
}
§§goto(addr30);
}
private function e_GAME_EXIT(param1:Event = null) : void
{
e_GAME_COMPLETE(param1,"exit");
}
}
}